package com.a2j.beans.enums;

import lombok.val;

/**
 * Author: bzb
 * Data: 2021/11/18 22:20
 * Desc: 货源渠道
 */
public enum SourceTypeEnum {
    // 平行进口 中规进口 国产
    平行进口(1, "平行进口"),
    中规进口(2, "中规进口"),
    国产(3, "国产");

    private int type;
    private String desc;

    SourceTypeEnum(int type, String desc) {
        this.type = type;
        this.desc = desc;
    }

    public static int getType(String desc) {
        if (desc == null) return -1;
        val enums = values();
        for (SourceTypeEnum um : enums) {
            if (desc.equals(um.desc)) return um.type;
        }
        return -1;
    }

    public static String getDesc(int type) {
        val enums = values();
        for (SourceTypeEnum um : enums) {
            if (type == um.type) return um.desc;
        }
        return "";
    }

}
